new Vue({
    el: '#app',
    data: {
        userData: {
            username: '',
            password: '',
            name:'',
            quanxian:'',
        },
        registDialogVisible:false,
        quanxian:
            [{
                value: '1',
                label: '全国',
            }, {
                value: '2',
                label: '校园',
            }],
    },
    methods: {
        login: function () {
            var _this = this;
            console.log("login")
            $.ajax({
                url: '/Login',
                data: {
                    username: _this.userData.username,
                    password: _this.userData.password
                },
                type: 'POST',
                dataType: 'Json',
                success: function (data) {
                    if(data.code== '200'){
                        $(window).attr('location', 'entry');
                    }else if(data.code == '201'){
                        _this.$message.error('登录失败，用户名或密码错误！');
                    }else if(data.code == '403'){
                        _this.$alert('账号权限不足！', '账号权限不足！', {
                            confirmButtonText: '确定'
                        });
                    }else{

                    }
                    console.log("success")
                    console.log(data)
                },
                erroe: function () {
                    console.log(1)
                }
            });
        },
        registNewdialog:function(){
            this.registDialogVisible = true;
        },
        regist: function () {
            var _this = this;
            console.log(1);
            $.ajax({
                url: 'common/regist',
                data: {
                    username: _this.userData.username,
                    password: _this.userData.password,
                    name: _this.userData.name,
                    quanxian: _this.userData.quanxian
                },
                type: 'post',
                dataType: 'Json',
                // async:'false',
                success: function (data) {
                    if(data.code = '1'){
                        _this.$message({
                            showClose: true,
                            message: '注册成功',
                            type: 'success'
                        });
                        _this.registDialogVisible = false;
                    }else{
                        _this.$message.error('注册失败');
                    }
                },
                erroe: function () {
                    _this.$message.error('系统异常');
                }
            });
        },
    },
})